/* CTemplate: ctemplate.c
   Description */
#include <stdio.h>

/* prototypes */
float calculateCharges( float time );

/* function main begins program execution */
int main( void )
{
    float time1, time2, time3;

    printf( "Enter the time of car 1: " );
    scanf( "%f", &time1 );
    printf( "Enter the time of car 2: " );
    scanf( "%f", &time2 );
    printf( "ENter the time of car 3: " );
    scanf( "%f", &time3 );

    printf( "%7s%15s%15s\n", "Car", "Hours", "Charge" );
    printf( "%7d%15.1f%15.2f\n", 1, time1, calculateCharges( time1 ) );
    printf( "%7d%15.1f%15.2f\n", 2, time2, calculateCharges( time2 ) );
    printf( "%7d%15.1f%15.2f\n", 3, time3, calculateCharges( time3 ) );
    printf( "%7s%15.1f%15.2f\n", "TOTAL", time1 + time2 + time3, calculateCharges( time1 ) + calculateCharges( time2 ) + calculateCharges( time3 ) );

	return 0;
} /* end function main */

float calculateCharges( float time )
{
    float charge;
    if ( time <= 3 ) {
        charge = 2.00;
    }
    else {
        charge = 2.00 + 0.5 * ( time - 3 );
    }

    return charge > 10.0 ? 10.0 : charge;
}
